using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEditor;
using SgsUI;

namespace SgsUI.Editor
{
    [CustomEditor(typeof(SgsUI.ViewLabel))]
    [CanEditMultipleObjects]
    public class ViewLabelEditor : ViewEditorBase
    {
        ViewLabel m_label;

        private List<string> m_key_map = new List<string>
        {
            "text","color","fontsize"
        };
        private Dictionary<string,SerializedProperty> m_prop = new Dictionary<string,SerializedProperty>();

        protected override void OnEnable()
        {
            base.OnEnable();
            foreach(string key in m_key_map)
            {
                m_prop[key] = serializedObject.FindProperty(key);
            }
            m_label = target as ViewLabel;
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            m_label.UpdateLabel();
            serializedObject.ApplyModifiedProperties();
 
            serializedObject.Update();
            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_prop["text"]);
            EditorGUILayout.PropertyField(m_prop["color"]);
            EditorGUILayout.PropertyField(m_prop["fontsize"]);
            GUI.enabled = true;
        }
    }
}
